package com.lobov.run.hadoop;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.input.TextInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat;

public class Dictionary {
	 public static void main(String[] args) throws Exception
	    {
	        Configuration conf = new Configuration();
	        Job job = new Job(conf, "dictionary");
	        job.setJarByClass(Dictionary.class);
	        job.setMapperClass(WordMapper.class);
	        job.setReducerClass(AllTranslationsReducer.class);
	        job.setOutputKeyClass(Text.class);
	        job.setOutputValueClass(Text.class);

	        job.setMapOutputKeyClass(Text.class);
	        job.setMapOutputValueClass(Text.class);

	        job.setInputFormatClass(TextInputFormat.class);
	        job.setOutputFormatClass(TextOutputFormat.class);
	        
	        FileInputFormat.addInputPath(job, new Path(args[0])); 
	        FileOutputFormat.setOutputPath(job, new Path(args[1]));
	        boolean result = job.waitForCompletion(true);
	        System.exit(result ? 0 : 1);
	        
	        
	        
	        
//	        Text text = new Text();
//	        MatrixYale m1 = Generator.generateUnCompressedHorisontalMatrixYale(
//					10, 10, 0.2);
//	        byte[] bytes = SerializationUtils.serialize(m1);
//	        text.set(bytes);
	    }
}
